import { Column, Entity, OneToMany } from 'typeorm';
import { BaseEntity } from '../../../common/baseEntity/index';
import { Article } from '../../article/entities/article.entity';
// 分类表
@Entity('classification')
export class Classification extends BaseEntity {
  @Column({ type: 'varchar', length: 50, comment: '分类名称' })
  name: string;

  @Column({ type: 'int', default: 0, comment: '排序' })
  sort: number;

  @Column({
    type: 'varchar',
    name: 'p_id',
    nullable: true,
    length: 50,
    comment: '父分类id',
  })
  pId: string;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '链接' })
  sulg: string;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '关键词' })
  keywords: string;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '描述' })
  description: string;

  // 通过第二个参数指定外键列在 article.classification 维护
  @OneToMany(() => Article, (article) => article.classification, {})
  articles: Article[];
  
}
